package com.elh.nio.server;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author liulei
 **/
public class Server1 {

    public static void main(String[] args) throws IOException {
        byte[] bytes = new byte[1024];
        ServerSocket serverSocket = new ServerSocket(8088);
        System.out.println("accept begin " + System.currentTimeMillis());
        // 阻塞效果
        Socket socket = serverSocket.accept();
        System.out.println("accept end " + System.currentTimeMillis());
        // 输入流中获得数据
        InputStream inputStream = socket.getInputStream();
        // 阻塞效果
        int read = inputStream.read(bytes);
        System.out.println("read end " + System.currentTimeMillis());
        inputStream.close();
        socket.close();
    }

}
